import 'package:flutter/material.dart';

class ServiceNotificationPage extends StatelessWidget {
  const ServiceNotificationPage({super.key});

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      backgroundColor: const Color(0xFFF7F7F7),
      appBar: AppBar(
        title: const Text(
          '服务通知',
          style: TextStyle(
            fontWeight: FontWeight.w600,
            color: Colors.white,
          ),
        ),
        centerTitle: true,
        backgroundColor: Theme.of(context).colorScheme.primary,
        leading: IconButton(
          icon: const Icon(Icons.arrow_back, color: Colors.white),
          onPressed: () => Navigator.of(context).pop(),
        ),
      ),
      body: ListView.builder(
        padding: EdgeInsets.zero,
        itemCount: _getNotifications().length,
        itemBuilder: (context, index) {
          final notification = _getNotifications()[index];
          return _buildNotificationItem(notification);
        },
      ),
    );
  }

  Widget _buildNotificationItem(NotificationItem notification) {
    return Container(
      decoration: const BoxDecoration(
        color: Colors.white,
        border: Border(
          bottom: BorderSide(
            color: Color(0xFFEEEEEE),
            width: 0.5,
          ),
        ),
      ),
      padding: const EdgeInsets.all(15),
      child: Column(
        crossAxisAlignment: CrossAxisAlignment.start,
        children: [
          Row(
            mainAxisAlignment: MainAxisAlignment.spaceBetween,
            children: [
              Text(
                notification.title,
                style: const TextStyle(
                  fontSize: 16,
                  fontWeight: FontWeight.w600,
                ),
              ),
              Text(
                notification.time,
                style: TextStyle(
                  fontSize: 12,
                  color: Colors.grey[500],
                ),
              ),
            ],
          ),
          const SizedBox(height: 8),
          Text(
            notification.content,
            style: TextStyle(
              fontSize: 14,
              color: Colors.grey[600],
              height: 1.5,
            ),
          ),
          if (notification.actionText != null) ...[
            const SizedBox(height: 12),
            InkWell(
              onTap: () {
                // 处理操作按钮点击
              },
              child: Container(
                padding: const EdgeInsets.symmetric(
                  horizontal: 12,
                  vertical: 6,
                ),
                decoration: BoxDecoration(
                  color: Colors.blue.withOpacity(0.1),
                  borderRadius: BorderRadius.circular(4),
                ),
                child: Text(
                  notification.actionText!,
                  style: const TextStyle(
                    color: Colors.blue,
                    fontSize: 13,
                  ),
                ),
              ),
            ),
          ],
        ],
      ),
    );
  }

  List<NotificationItem> _getNotifications() {
    return [
      NotificationItem(
        title: '搬家订单已完成',
        content: '您的订单 #12345 已完成服务。感谢您的使用，期待再次为您服务！',
        time: '10:30',
        actionText: '查看订单',
      ),
      NotificationItem(
        title: '师傅已出发',
        content: '搬家师傅已出发，预计20分钟后到达。如有问题请及时联系客服。',
        time: '昨天 15:20',
      ),
      NotificationItem(
        title: '订单已确认',
        content: '您的搬家订单已确认，订单金额 ¥299，请保持手机畅通。',
        time: '昨天 14:30',
        actionText: '查看详情',
      ),
      NotificationItem(
        title: '系统升级通知',
        content: '系统将于今晚22:00-23:00进行升级维护，期间可能影响部分功能使用。',
        time: '前天',
      ),
      NotificationItem(
        title: '评价提醒',
        content: '您的搬家订单服务已完成，请对本次服务进行评价，您的建议是我们进步的动力。',
        time: '前天',
        actionText: '立即评价',
      ),
    ];
  }
}

class NotificationItem {
  final String title;
  final String content;
  final String time;
  final String? actionText;

  NotificationItem({
    required this.title,
    required this.content,
    required this.time,
    this.actionText,
  });
} 